package com.sky.mapper.admin;


import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Employee;
import org.apache.ibatis.annotations.*;



public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    @Insert("insert into employee(name,username,password,phone,sex,id_number,status,create_time,create_user,update_time,update_user) \n" +
            "values(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{createUser},#{updateTime},#{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    void addEmployee(Employee employee);


    Page<Employee> pageQuery(EmployeePageQueryDTO dto);

    @Update("update employee set status=#{status} where id = #{id}")
    void startOrStop(@Param("status") int status, @Param("id") long id);

    /**
     * 根据id查询员工信息
     * @param id
     * @return
     */
    @Select("select * from employee where id = #{id}")
    Employee getById(Long id);
    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);
}
